﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="OneMG.Phoenix.AdminSite.Views.Product.Index" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">作品管理
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadScripts" runat="server">
    <script type="text/javascript" src="/Scripts/m-lhgdialog/m-lhgdialog.js"></script>    

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
            <form id="form1" runat="server">

    <div class="path">
        <a href="/productcategory/index"><strong>作品管理</strong></a>
    </div>
    <div class="pd10">
        <div class="mb10 aL">
            <a href="/Views/Product/Edit.aspx" title="添加作品" class="a-btn1" >添加作品</a>
            <a href="/Views/Category/index.aspx?pid=2" title="作品分类" class="a-btn1" >作品分类</a>
            <span style="float:right;">按分类查看
                    <select id="sltCategoryID" name="sltCategoryID">
                    <option value="0">所有</option>
                        <%foreach (OneMG.Phoenix.Service.Model.CategoryModel c in CategoryList)%>
                        <%{%>
                            <% if (CategoryID == c.CategoryID) %>
                            <%{%>
                                <option value="<%=c.CategoryID %>" selected="selected"> <%=c.CategoryName%></option>
                            <%}%>
                            <%else %>
                            <%{ %>
                                 <option value="<%=c.CategoryID %>"><%=c.CategoryName%></option>
                            <%} %>
                        <%}%>
                    </select>

            </span>
        </div>
        
        
        <span id="Grid">
<table class="tb-list hover">
    <tr>
        <th>
            编号
        </th>
        <th>
            标题
        </th>
        <th>
            分类
        </th>
        <th>
            发布时间
        </th>
        <th width="20%">
            操作
        </th>
    </tr>
   <% foreach (OneMG.Phoenix.Service.Model.ProductModel item in listModle) %>
    <%{%>
    <tr>
    <td style="width:10%">
           <%=item.ProductID %>
        </td>
        <td style="width:30%">
           <%=item.Title %>
        </td>
         <td style="width:20%">
           <%=item.CategoryName %>
        </td>         
        <td style="width:20%">
           <%=item.CreateTime %>
        </td>
        <td style="width:20%">
            <a href="Edit.aspx?pid=<%=item.ProductID %>&cid=<%=item.CateID %>">编辑</a> <a href="javascript:;" onclick="DeleteProduct('<%=item.ProductID %>')">删除</a>
        </td>
    </tr>
<%}%>
</table>
        </span>
            <!-- 分页插件  -->
        <div id="pager" class="aR mt10">
            <webdiyer:AspNetPager ID="AspNetPager1" runat="server" 
                onpagechanged="AspNetPager1_PageChanged" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" PageSize="1" >
            </webdiyer:AspNetPager>
        </div>

    </div>
    </form>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="Scripts" runat="server">

<script type="text/javascript" src="/Scripts/library/m-pagination.js"></script>    
    <script type="text/javascript">
        
        // 删除类目
        function DeleteProduct(productID) {
            if (confirm("确认删除吗?") == false) {
                return;
            }

            $.ajax({
            url: "/Views/Product/Save.ashx",
            data: { "productid": productID },
                type: "POST",
                success: function(data, textStatus) {
                    if (data.status === "warning" || data.status === "error") {
                        alert(data.msg);
                        return false;
                    }
                    // 刷新列表
                    refresh();
                },
                error: function(XmlHttpRequest, textStatus, errorThrown) {
                alert(errorThrown);
                }
            });
        };
        
</script> 
</asp:Content>
